"""
    @author yu_chen
    @date  
    @todo 
"""
import os

from spider_comments.CloudMusicComments import GetComments


def run(process_index, song_list_id_names):
    """
    :param process_index: 进程号
    :return:
    """
    # 给出歌单ID即可
    for index in range(50):
        song_list_id_name = song_list_id_names[process_index + index * 7]
        song_list_id = song_list_id_name.split(',', 1)[0]
        song_list_name = song_list_id_name.split(',', 1)[1].replace('\n', '')
        # print(song_list_id + "----" + song_list_id_name)
        # 列出文件列表
        file_list = os.listdir('../txt')
        if song_list_name + '.txt' not in file_list:
            print(song_list_name + "-------不存在")
            singer_url = 'https://music.163.com/playlist?id=' + song_list_id  # 记得要去掉#号，太那啥了
            spider = GetComments()
            spider.current_songs_list_name = song_list_name
            spider.get_songs_id(singer_url)
        else:
            print(song_list_name + "-------已经存在")


if __name__ == '__main__':
    # 将文件内容全部读取入数组中
    with open('../resource/all_songs_list_ids.txt', 'r') as f:
        song_list_id_names = f.readlines()
        f.close()
    run(0, song_list_id_names)
